﻿using System;
using System.ComponentModel;

namespace Morse
{
    public class MorseCode:INotifyPropertyChanged
    {

        public static int Dit = 100, Dah = 300;

        private string _text;
        private string _code;

        public MorseCode()
        {
        }

        public string Text
        {
            get { return _text; }
            set
            {
                if (value != _text)
                {
                    _text = value;
                    OnPropertyChanged("Text");
                    Code = MorseEncode.Encode(_text);
                }
            }
        }

        public string Code
        {
            get { return _code; }
            set
            {
                if (value != _code)
                {
                    _code = value;
                    OnPropertyChanged("Code");
                }
            }
        }

        #region INotifyPropertyChanged Members

        public event PropertyChangedEventHandler PropertyChanged;

        protected void OnPropertyChanged(string name)
        {
            var eh = PropertyChanged;
            if (eh != null)
            {
                eh(this, new PropertyChangedEventArgs(name));
            }
        }
        #endregion
    }
}
